function [u, v] = powerM( A,B , x,maxIter, tol )
%POWERMethod
%   Input: matrix X
%   Output: the left and right singular value of X
err = zeros(maxIter, 1);
u = A * (B*(B'*(A'*x)));
u = u/norm(u);

for i =1:maxIter
    u1 = A * (B*(B'*(A'*u)));

    u1 = u1/norm(u1);
    err(i) = norm(u1-u);
    if( err(i) < tol)
        break;
    end  
    u = u1;
end
    
    maxIter = i; 
    display(maxIter);

    v = B'*(A'*u);
    v = v/norm(v);
end

